package 对象序列化流;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/*
构造方法：
ObjectInputStream (InputStream in):创建指定的InputStream读取的ObjectInputStream

反序列化对象的方法：
Object readObject ():从ObjectInputStream读取一个对象
 */
public class ObjectInputStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //ObjectInputStream (InputStream in):创建指定的InputStream读取的ObjectInputStream
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("oos.txt"));

        //Object readObject ():从ObjectInputStream读取一个对象
        Object obj = ois.readObject();

        Student s=(Student) obj;//向下转型
        System.out.println(s.getName()+","+s.getAge());//读取了序列化流的对象

        ois.close();
    }
}
